<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    
	
	<title>_${customer.customerName}_上架任务</title>
	<script type="text/javascript">
	        
	     //美化车载信息
		function formatCarInfo(carInfo) {
			var carInfoArray = carInfo.split(";");
			var temp = '';
			for ( var i = 0; i < carInfoArray.length; i++) {
				var car = carInfoArray[i];
				if (car == null || car == '') {
				} else {
					temp += "【" + car + "(件)】";
				}
			}
			return temp;
		}
		
		//领取任务
		function takeTask(taskId){
		  $.ajax({
			type : 'post',
			url : '${ctx}/cusInstorageAudit/ajaxTakeTask',
			data : {
				taskId:taskId
			},
			dataType : 'json',
			success : function(data) {
			   var msg=data.msg;
				if (msg == "success") {
					location.reload();
				}else if(msg=="token"){
				    alert("此任务已被分配。");
				    location.reload();
				} else {
					alert("网络繁忙，请稍后重试...");
				}
			},
			error : function() {
				alert("网络繁忙，请稍后重试...");
			}
		});
		
	 }
		
    </script>
</head>

<body>
	<div style="height: 10px;"></div>
	
	<!-- 我的任务 -->
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
	    <thead>
			<th style="vertical-align: middle; color: white;" colspan="13" bgcolor="#8EB4CB">我的上架任务</th>
		</thead>
		<thead><tr>
		    <th style="width: 100px;">商家</th>
		    <th style="width: 100px;">仓库</th>
		    <th style="width: 100px;">任务批次号</th>
		    <th style="width: 50px;">上架类型</th>
		    <th style="width: 50px;">入库类型</th>
		    <th style="width: 100px;">入库单号</th>
			<th style="width: 50px;">车编号</th>
			<th style="width: 100px;">车载货信息</th>
			<th style="width: 100px;">任务开始时间</th>
<%--			<th style="width: 80px;">指派人</th>--%>
<%--			<th style="width: 80px;">执行人</th>--%>
			<th style="width: 80px;">任务状态</th>
			<th style="width: 80px;">操作</th>
		</tr></thead>
		<tbody>
		<c:forEach items="${taskList}" var="task">
			<tr>
			    <td>${task.batch.bill.customer.customerName}</td>
			    <td>${task.batch.bill.inwarehouse.groupName}</td>
			    <td>${task.taskBatch}</td>
			    <td>
			       <c:if test="${task.carType eq '1' }"><font color='blue'>整箱件</font></c:if>
			       <c:if test="${task.carType eq '2' }">散货件</c:if>
			       <c:if test="${task.carType eq '3' }"><font color='red'>破损件</font></c:if>
			    </td>
			    <td>
			      <c:if test="${task.batch.bill.billType eq '1' }"><font color='blue'>总仓入库</font></c:if>
			      <c:if test="${task.batch.bill.billType eq '2' }"><font color='blue'>调拨入库</font></c:if>
			    </td>
			    <td>${task.batch.bill.instorageCode}</td>
			     <td>${task.carNo}号车</td>
			    <td>
			       <script type="text/javascript">document.write(formatCarInfo('${task.carInfo}'));</script>
			    </td>
			    <td>${fn:substring(task.startTime,0,19)}</td>
<%--			    <td>${task.commander.realname}</td>--%>
<%--			    <td>${task.worker.realname}</td>--%>
			    <td>
			      <c:if test="${task.status eq '1'}">待执行...</c:if>
			      <c:if test="${task.status eq '2'}">开始执行任务</c:if>
			      <c:if test="${task.status eq '3'}">任务完成</c:if>
			      <c:if test="${task.status eq '4'}">任务异常</c:if>
			    </td>
				<td>
				   <c:if test="${task.carType eq '1'}">
				     <a href="${ctx}/cusInstorageUpshelf/upshelf_box/${task.id}" data-toggle="modal" class="btn btn-info" >执行任务</a>
				   </c:if>
				   <c:if test="${task.carType ne '1'}">
				     <a href="${ctx}/cusInstorageUpshelf/upshelf/${task.id}" data-toggle="modal" class="btn btn-info" >执行任务</a>
				   </c:if>
				   
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
	
	<!-- 未指派任务 -->
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
	    <thead>
			<th style="vertical-align: middle; color: white;" colspan="13" bgcolor="#8EB4CB">未指派任务</th>
		</thead>
		<thead><tr>
		    <th style="width: 100px;">商家</th>
		    <th style="width: 100px;">仓库</th>
		    <th style="width: 100px;">任务批次号</th>
		    <th style="width: 50px;">上架类型</th>
		    <th style="width: 50px;">入库类型</th>
		    <th style="width: 100px;">入库单号</th>
			<th style="width: 50px;">车编号</th>
			<th style="width: 100px;">车载货信息</th>
			<th style="width: 100px;">任务开始时间</th>
			<th style="width: 80px;">任务状态</th>
			<th style="width: 80px;">操作</th>
		</tr></thead>
		<tbody>
		<c:forEach items="${untaskList}" var="task">
			<tr>
			    <td>${task.batch.bill.customer.customerName}</td>
			    <td>${task.batch.bill.inwarehouse.groupName}</td>
			    <td>${task.taskBatch}</td>
			    <td>
			       <c:if test="${task.carType eq '1' }"><font color='blue'>整箱件</font></c:if>
			       <c:if test="${task.carType eq '2' }">散货件</c:if>
			       <c:if test="${task.carType eq '3' }"><font color='red'>破损件</font></c:if>
			    </td>
			    <td>
			      <c:if test="${task.batch.bill.billType eq '1' }"><font color='blue'>总仓入库</font></c:if>
			      <c:if test="${task.batch.bill.billType eq '2' }"><font color='blue'>调拨入库</font></c:if>
			    </td>
			    <td>${task.batch.bill.instorageCode}</td>
			    <td>${task.carNo}号车</td>
			    <td>
			       <script type="text/javascript">document.write(formatCarInfo('${task.carInfo}'));</script>
			    </td>
			    <td>${task.startTime }</td>
			    <td>
			      <c:if test="${task.status eq '0'}">未指派...</c:if>
			      <c:if test="${task.status eq '1'}">待执行...</c:if>
			      <c:if test="${task.status eq '2'}">开始执行任务</c:if>
			      <c:if test="${task.status eq '3'}">任务完成</c:if>
			      <c:if test="${task.status eq '4'}">任务异常</c:if>
			    </td>
				<td>
				    <a href="#" data-toggle="modal" class="btn btn-info" onclick="takeTask('${task.id}');return false;">领取任务</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
	
</body>
</html>
